package stu.aistar.service.Impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import stu.aistar.mapper.CinameMapper;
import stu.aistar.model.pojo.Ciname;
import stu.aistar.service.CinameService;

import java.util.List;

@Service
public class CinameServiceImpl implements CinameService {
    @Autowired
    private CinameMapper cinameMapper;

    @Override
    public List<Ciname> findAll() {
        return cinameMapper.findAll();
    }

    @Override
    public PageInfo<Ciname> findByPage(String page,String pageSize,String name){
        PageHelper.startPage(Integer.parseInt(page),Integer.parseInt(pageSize));
        PageInfo<Ciname> pageInfo = new PageInfo<>(cinameMapper.findAllByName(name));
        return pageInfo;
    }

    @Override
    public Integer getTotal() {
        return cinameMapper.getTotal();
    }


    @Override
    public Integer saveMovie(Ciname ciname) {
        return cinameMapper.insertCiname(ciname);
    }

    @Override
    public Integer deleteCinameById(Integer id) {
        return cinameMapper.delCinameById(id);
    }

    @Override
    public Ciname findByCinameId(Integer id) {
        return cinameMapper.findById(id);
    }

    @Override
    public Integer editCiname(Ciname ciname) {
        return cinameMapper.editCiname(ciname);
    }


}
